<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>知识库详情</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<!-- jQuery-->
		<script type="text/javascript" src="/static/plugins/jquery/jquery-3.6.0.min.js"></script>

		<!-- layui-->
		<link rel="stylesheet" href="/static/plugins/layui/2.8.4/css/layui.css" media="all">
		<script src="/static/plugins/layui/2.8.4/layui.js" charset="utf-8"></script>
		
		
	</head>
	<style>
		.all-view{
			width: 90%;
			margin: 0 auto;
			margin-top: 20px;
		}
		.btn-view{
			margin-bottom: 10px;
			
		}
		.add-btn{
			width:120px;
		}
		.bottom-view{
			position: fixed;
			bottom: 0;
			width: 100%;
		}
		.add-btn-view{
			width: 260px;
			margin: 0 auto;
			margin-bottom: 40px;
		}
	</style>
	
	<body>
		
		<!--头部输入框-->
		
		<form class="layui-form layui-form-pane all-view" action="">



			<div class="layui-form-item">
				<label class="layui-form-label">分类：</label>
				<div class="layui-input-block" >
					<span name="chooseType" id="chooseType" style="line-height: 36px;padding-left: 10px;"></span>
				</div>
			</div>


		
			<div class="layui-form-item layui-form-text" id="general-txt">
				<label class="layui-form-label">内容</label>
				<div class="layui-input-block">
				  <textarea placeholder="请输入内容" class="layui-textarea" id="information" style="white-space: pre-line;height: 200px;" maxlength="300" readonly></textarea>
					<div><span id="textCount">0</span>/<span id="inputMaxTxt">300</span></div>
				</div>
			  </div>


      </form>


		<input type="hidden" name="id" id="id" value=""><!--信息id-->
		<input type="hidden" name="baseId" id="baseId" value=""><!--知识库id-->
		<input type="hidden" name="typeId" id="typeId" value=""><!--所选择的类型id-->


      <script>
		  $('#id').val('[(${dto.id})]');


		  $.ajax({
			  url : '/api/inter/knowledgeList/searchKnowledgeListById',
			  data : {id:$('#id').val()},
			  type : 'POST',
			  async : false,
			  success : function(result) {
				  if(result.code=='SUCCESS'){
				  		var chooseType = '';
					  var eKnowKnowledgeList = result.eKnowKnowledgeList;
					  if(eKnowKnowledgeList!=null){
						  $('#baseId').val(eKnowKnowledgeList.baseId);
						  $('#typeId').val(eKnowKnowledgeList.typeId);
						  $('#information').val(eKnowKnowledgeList.information);
						  var information = document.getElementById('information');
						  $('#textCount').text(txtCount(information));


					  }
					  var eKnowKnowledgeTypeList = result.eKnowKnowledgeTypeList;
					  if(eKnowKnowledgeTypeList!=null && eKnowKnowledgeTypeList.length>0){
					  	for(var i=0;i<eKnowKnowledgeTypeList.length;i++){
					  		if(eKnowKnowledgeTypeList[i].id == $('#typeId').val()){
								$('#chooseType').text(eKnowKnowledgeTypeList[i].typeName);
							}
						}

					  }

				  }else{
					  layer.msg('不好意思，系统出现问题了，请稍后重试！', {icon: 2});
					  setTimeout(function(){
						  window.parent.layer.closeAll();
					  }, 1000);
				  }
			  }
		  });

		  //var information = $('#information').val();
		  var information = document.getElementById('information');
		  $('#textCount').val(txtCount(information));


          layui.use(function(){
            var form = layui.form;
            var layer = layui.layer;

			  form.on('select(chooseType)', function(data){
				  //var elem = data.elem; // 获得 select 原始 DOM 对象
				  var value = data.value; // 获得被选中的值
				  //var othis = data.othis; // 获得 select 元素被替换后的 jQuery 对象
				  $('#typeId').val(value);
			  });



          });

		  function toClose() {
			  window.parent.layer.closeAll();
		  }




		  //输入框底下的字数变化监听
		  var el = document.getElementById('information');
		  el.addEventListener('input',function () {
			  var len =  txtCount(this); //   调用函数
			  document.getElementById('textCount').innerHTML = len;
		  });

		  //函数 - 获取文本内容和长度
		  function txtCount(el) {
			  var val = el.value;
			  var eLen = val.length;
			  return eLen;
		  }
      </script>

  </body>
</html>